<?php

/**
 * Appointment filter form base class.
 *
 * @package    docplus.co.za
 * @subpackage filter
 * @author     Fox Matuku
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseAppointmentFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'time_slot_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TimeSlot'), 'add_empty' => true)),
      'doctor_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Doctor'), 'add_empty' => true)),
      'member_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Member'), 'add_empty' => true)),
      'is_for_yourself'       => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'is_using_insurance'    => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'has_reminder'          => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'appointment_reason_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('VisitReason'), 'add_empty' => true)),
      'status'                => new sfWidgetFormChoice(array('choices' => array('' => '', 'Cancelled' => 'Cancelled', 'Missed' => 'Missed', 'Held' => 'Held', 'Pending' => 'Pending', 'Approved' => 'Approved'))),
      'note_by_doctor'        => new sfWidgetFormFilterInput(),
      'note_by_member'        => new sfWidgetFormFilterInput(),
      'created_at'            => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'            => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'time_slot_id'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('TimeSlot'), 'column' => 'id')),
      'doctor_id'             => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Doctor'), 'column' => 'id')),
      'member_id'             => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Member'), 'column' => 'id')),
      'is_for_yourself'       => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'is_using_insurance'    => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'has_reminder'          => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'appointment_reason_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('VisitReason'), 'column' => 'id')),
      'status'                => new sfValidatorChoice(array('required' => false, 'choices' => array('Cancelled' => 'Cancelled', 'Missed' => 'Missed', 'Held' => 'Held', 'Pending' => 'Pending', 'Approved' => 'Approved'))),
      'note_by_doctor'        => new sfValidatorPass(array('required' => false)),
      'note_by_member'        => new sfValidatorPass(array('required' => false)),
      'created_at'            => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'            => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('appointment_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Appointment';
  }

  public function getFields()
  {
    return array(
      'id'                    => 'Number',
      'time_slot_id'          => 'ForeignKey',
      'doctor_id'             => 'ForeignKey',
      'member_id'             => 'ForeignKey',
      'is_for_yourself'       => 'Boolean',
      'is_using_insurance'    => 'Boolean',
      'has_reminder'          => 'Boolean',
      'appointment_reason_id' => 'ForeignKey',
      'status'                => 'Enum',
      'note_by_doctor'        => 'Text',
      'note_by_member'        => 'Text',
      'created_at'            => 'Date',
      'updated_at'            => 'Date',
    );
  }
}
